package com.kelvem.saas.workbanch.ontology.piaoorder.event;

import com.kelvem.saas.workbanch.fsm.container.DaoContainer;
import com.kelvem.saas.workbanch.fsm.dao.BaseDao;
import com.kelvem.saas.workbanch.fsm.core.EventContext;
import com.kelvem.saas.workbanch.fsm.core.FsmException;
import com.kelvem.saas.workbanch.fsm.handle.Handle;
import com.kelvem.saas.workbanch.fsm.entity.FsmEventReq;
import com.kelvem.saas.workbanch.ontology.piaoorder.model.PiaoOrderEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author kelvem
 */
@Service
@Slf4j
public class LoadDataHandle extends Handle {
    
    @Override
    public void execute() {
        try {
            FsmEventReq req = (FsmEventReq) EventContext.getRequest();
    
            BaseDao dao = DaoContainer.getDao(req.getEntityType() + "Dao");
            
            PiaoOrderEntity order = (PiaoOrderEntity)dao.selectById(req.getEntityId());
            EventContext.addContext(order);
            
        } catch (Exception e) {
            throw new FsmException(e.getMessage(), e);
        }
    }
}
